

<div id="app">
    <el-card class="box-card">
        <el-form :inline="true">
            <el-form-item label="盘点单号：" label-width="100px">
                <div style="display: flex;width: 300px;">
                    <el-input v-model="data.check_no" placeholder="请输入盘点单号"></el-input>
                    <el-button type="primary" icon="el-icon-search" @click="get_list" ></el-button>
                </div>
            </el-form-item>
            <el-form-item label="盘点时间：" label-width="100px">
                <div style="display: flex;width: 300px;">
                    <el-date-picker
                            v-model="value1"
                            type="datetimerange"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :default-time="['00:00:00']">
                    </el-date-picker>
                    <el-button type="primary" icon="el-icon-search" @click="get_list_time" ></el-button>
                </div>
            </el-form-item>
        </el-form>
        <el-button type="primary" size="small" @click="onSubmit">新建盘点单</el-button>
        <div style="height: 30px;"></div>
        <el-table v-if="dataArr.length>0"
                  :data="dataArr"
                  border
                  style="width: 100%">
            <el-table-column
                    prop="id"
                    label="ID"
                    width="50">
            </el-table-column>
            <el-table-column
                    prop="check_no"
                    label="盘点单号"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="check_name"
                    label="盘点单名称"
            >
            </el-table-column>

            <el-table-column
                    prop="employee_name"
                    label="盘点人"
            >

            </el-table-column>
            <el-table-column
                    prop="create_time"
                    label="盘点时间"
            >

            </el-table-column>

            <el-table-column
                    prop="status"
                    label="盘点状态"
            >
                                <template slot-scope="{row}">
                                    <span v-if="row.status==1">待盘点</span>
                                    <span v-else-if="row.status==2">盘点中</span>
                                    <span v-else-if="row.status==3">盘点完成</span>
                                </template>
            </el-table-column>

            <el-table-column
                    prop="remark"
                    label="备注"
            >
            </el-table-column>

            <el-table-column label="操作" width="200">
                <template slot-scope="{row}">
                    <div>
                        <div v-if="row.status==1">
                            <el-button type="text" size="mini" @click="do_pandian(row)">开始盘点</el-button>
                            <el-button type="text" size="mini" @click="edit_show(row)">编辑</el-button>
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" @click="exipt_world(row.id)">打印</el-button>
                            <el-button type="text" size="mini" @click="notes_show(row)">备注</el-button>
                            <el-button type="text" size="mini" @click="on_delete(row.id)">删除</el-button>
                        </div>  

                        <div v-else-if="row.status==2">
                            <el-button type="text" size="mini" @click="do_pandian(row)">继续盘点</el-button>
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" @click="exipt_world(row.id)">打印</el-button>

                            <el-button type="text" size="mini" @click="notes_show(row)">备注</el-button>
                            <el-button type="text" size="mini" @click="on_delete(row.id)">删除</el-button>
                        </div>
                        <div v-else-if="row.status==3">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" @click="exipt_world(row.id)">打印</el-button>
                            <el-button type="text" size="mini" @click="notes_show(row)">备注</el-button>
                        </div>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="10"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </div>
    </el-card>
    <el-dialog
            :visible.sync="dialogVisible"
            width="70%"

    >
        <div v-if="active_int===1">
            <div style="border: 1px solid rgba(232, 232, 232, 1);margin-bottom: 20px;">
                <div class="border">
                    <fieldset class="layui-elem-field layui-field-title" >
                        <legend style="font-weight: bold;font-size: 16px;">盘点单信息</legend>
                    </fieldset>
                    <!--                    <div class="tit"></div>-->
                    <table style="width: 100%;line-height: 2;margin: 20px" class="table">
                        <tr>
                            <td>盘点单号：{{detail_obj.check_no}}</td>
                            <td>盘点单名称：{{detail_obj.check_name}}</td>
                            <td>盘点人：{{detail_obj.employee_name}}</td>
                        </tr>
                        <tr>
                            <td>盘点状态：
                                <span v-if="detail_obj.status==1">待盘点</span>
                                <span v-else-if="detail_obj.status==2">盘点中</span>
                                <span v-else-if="detail_obj.status==3">盘点完成</span>
                            </td>
                            <td>盘点时间：{{detail_obj.create_time}}</td>
                        </tr>
                    </table>

                    <fieldset class="layui-elem-field layui-field-title" >
                        <legend style="font-weight: bold;font-size: 16px;">商品信息</legend>
                    </fieldset>
                    <el-table :data="detail_obj.checklist_item"
                              border>
                        <el-table-column label="序号" prop="id" width="110"></el-table-column>
<!--                        <el-table-column label="商品编号" prop="gid" width="110"></el-table-column>-->
                        <el-table-column label="商品" prop="good_name"></el-table-column>
<!--                        <el-table-column label="规格" prop="physical_inventory" width="110"></el-table-column>-->
                        <el-table-column label="商品分类" prop="good_type_name" width="110"></el-table-column>
                        <el-table-column label="库存" prop="stock" width="110"></el-table-column>
                        <el-table-column label="实际库存" prop="physical_inventory" width="110"></el-table-column>
                        <el-table-column label="备注" prop="remarks" width="110"></el-table-column>

                    </el-table>
                </div>
            </div>
            <div slot="footer" class="dialog-footer">
                <!--            <el-button @click="dialogVisible = false">取 消</el-button>-->
                <!--            <el-button type="primary" @click="dialogVisible = false">确 定</el-button>-->
            </div>
        </div>
        <div v-if="active_int===2">
            <div>
                <el-form :inline="true">
                    <el-form-item label="盘点单号：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input   :value="add_form.check_no" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="盘点单名称：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input   v-model="add_form.check_name" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="出库人：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input   :value="add_form.outbound_name" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                </el-form>
                <div style="display: flex; align-items: center;">
                    <span style="margin-right: 60px;font-weight: bold;">盘点商品</span>
                    <div>
                        <el-button @click="onEdit" size="mini">提交盘点单</el-button>
                        <el-button type="primary" @click="exit" size="mini">退出</el-button>
                    </div>
                </div>
                <div style="width: 500px;margin: 20px 0;">
                    <el-button type="primary" size="mini" @click="add_shop">添加商品</el-button>
<!--                    <el-button type="" size="mini" @click="onSave">删除</el-button>-->
                </div>
            </div>
            <div style="width: 700px;">
                <el-table :data="add_form.goodsc_item" border>
                    <el-table-column label="序号" prop="gid" width="110"></el-table-column>
<!--                    <el-table-column label="商品编号" prop="num" width="110"></el-table-column>-->
                    <el-table-column label="商品" prop="good_name"></el-table-column>
<!--                    <el-table-column label="规格" prop="num" width="110"></el-table-column>-->
                    <el-table-column label="商品分类" prop="good_type_name" width="110"></el-table-column>
                    <el-table-column label="库存" prop="stock" width="110"></el-table-column>
                    <el-table-column label="操作"  width="110">
                        <template slot-scope="{row}">
                            <el-button type="text" @click="del_good(row.gid)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
        <div v-if="active_int===3">
            <div>
                <el-form :inline="true">
                    <el-form-item label="盘点单号：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input  placeholder="" :value="add_form.check_no" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="盘点单名称：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input  placeholder="请输入盘点单名称" v-model="add_form.check_name" ></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="出库人：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input  placeholder="" :value="add_form.outbound_name" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                </el-form>
                <div style="display: flex; align-items: center;">
                    <span style="margin-right: 60px;font-weight: bold;">盘点商品</span>
                    <div>
                        <el-button @click="onSave" size="mini">提交盘点单</el-button>
                        <el-button type="primary" @click="exit" size="mini">退出</el-button>
                    </div>
                </div>
                <div style="width: 500px;margin: 20px 0;">
                    <el-button type="primary" size="mini" @click="add_shop">添加商品</el-button>
<!--                    <el-button type="" size="mini" @click="onSave">删除</el-button>-->
                </div>
            </div>
            <div style="width: 700px;">
                <el-table :data="add_form.goodsc_item" border>
                    <el-table-column label="序号" prop="gid" width="110"></el-table-column>
<!--                    <el-table-column label="商品编号" prop="num" width="110"></el-table-column>-->
                    <el-table-column label="商品" prop="good_name"></el-table-column>
<!--                    <el-table-column label="规格" prop="num" width="110"></el-table-column>-->
                    <el-table-column label="商品分类" prop="good_type_name" width="110"></el-table-column>
                    <el-table-column label="库存" prop="stock" width="110"></el-table-column>
                    <el-table-column label="操作"  width="110">
                        <template slot-scope="{row}">
                            <el-button type="text" @click="del_good(row.gid)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
        <div v-if="active_int===4">
            <div>
                <el-form :inline="true">
                    <el-form-item label="盘点单号：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input  placeholder="" :value="pandian_detail.check_no" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="盘点单名称：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input  placeholder="" v-model="pandian_detail.check_name" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="出库人：" label-width="100px">
                        <div style="display: flex;width: 200px;">
                            <el-input  placeholder="" :value="pandian_detail.outbound_name" :disabled="true"></el-input>
                        </div>
                    </el-form-item>
                </el-form>
                <div style="display: flex; align-items: center;">
                    <span style="margin-right: 60px;font-weight: bold;">盘点商品</span>
                    <div>
                        <el-button size="mini" type="primary"  @click="save_pandian(2)">保存</el-button>
                        <el-button type="primary" size="mini" @click="save_pandian(3)">结束盘点</el-button>
                    </div>
                </div>
            </div>
            <div style="width: 700px;margin-top: 20px;">
                <el-table :data="pandian_detail.goodsc_item" border>
                    <el-table-column label="商品" prop="good_name" width="110"></el-table-column>
                    <el-table-column label="商品分类" prop="good_type_name" width="110"></el-table-column>
                    <el-table-column label="库存" prop="stock" width="110"></el-table-column>
                    <el-table-column label="实际库存" prop="num" >
                        <template slot-scope="{row}">
                            <el-input v-model="row.physical_inventory"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="备注" prop="remarks" width="150">
                        <template slot-scope="{row}">
                            <el-input v-model="row.remarks"></el-input>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
        <el-dialog
                width="60%"
                :visible.sync="innerVisible"
                :before-close="handleCloseGoods"
                append-to-body>
            <div >
                <div>
                    <el-form :inline="true" :model="formInline" class="demo-form-inline">
                        <el-form-item label="商品分类">
                            <el-select v-model="formInline.good_type_id" placeholder="请选择">
                                <el-option label="全部" value=""></el-option>
                                <el-option v-for="item of good_type" :label="item.title" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="商品名称">
                            <el-input v-model="formInline.title" placeholder="请输入关键字"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="goodsarr">查询</el-button>
                        </el-form-item>
                    </el-form>
                </div>
                <div style="width: 700px;">
                    <el-table :data="goodsArr" border ref="multipleTable"
                              tooltip-effect="dark"
                              style="width: 100%"
                              @selection-change="handleSelectionChange">
                        <el-table-column
                                label="全选"
                                type="selection"
                                width="55">
                        </el-table-column>
                        <el-table-column label="商品名称" prop="title" ></el-table-column>
<!--                        <el-table-column label="商品规格" prop="num" width="110"></el-table-column>-->
                        <el-table-column label="商品分类" prop="good_type_name" width="110"></el-table-column>
                        <el-table-column label="库存" prop="stock" width="110"></el-table-column>
<!--                        <el-table-column label="商品状态"  width="110">-->
<!--                            <template slot-scope="{row}">-->
<!--                                <el-switch-->
<!--                                        v-model="row.status"-->
<!--                                >-->
<!--                                </el-switch>-->
<!--                            </template>-->
<!--                        </el-table-column>-->
                    </el-table>
                </div>
                <div style="width: 500px;margin: 20px 0;">
                    <el-button type="primary" size="mini" @click="add_success">确认添加</el-button>
                </div>
            </div>
        </el-dialog>
    </el-dialog>
    <el-dialog
            title="变更提示"
            :visible.sync="dialogVisible_change"
            width="30%"
    >
        <el-select v-model="change_info_val">
            <el-option label="收货信息"
                       :value="1"></el-option>
            <el-option label="订单商品"
                       :value="2"></el-option>
        </el-select>
        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible_change = false">取 消</el-button>
    <el-button type="primary" @click="success">确 定</el-button>
  </span>
    </el-dialog>
</div>
<script !src="">
    new Vue({
        el: '#app',
        data: function() {
            return {
                form:{},
                dataArr:[],
                labelPosition:'left',
                bh:'',
                value:false,
                value1:'',
                value2:'',
                data:{
                    page:1,
                    limit:10,
                    check_no:'',
                    status_time:'',
                    end_time:''
                },
                total:0,
                currentPage:1,
                dialogVisible: false,
                innerVisible:false,
                active_int:1,
                detail_obj:{},
                dialogVisible_change:false,
                change_info_val:1,
                change_info_id:'',
                pickerOptions:'',
                edit_detail:{},
                add_form:{
                    check_name:'',
                    check_no:'',
                    outbound_name:'',
                    outbound_uid:'',
                    goodsc_item:[]
                },
                order_code_form:{
                    bar_code:'123',
                    good_name:'测试'
                },
                get_goodsarr:[],
                multipleSelection:[],
                goodsArr:[],
                formInline:{
                    good_type_id:'',
                    title:''
                },
                good_type:[],
                pandian_detail:{}
            }
        },
        created(){
            this.get_list()
        },
        methods:{
            handleCloseGoods(done){
                this.goodsarr()
                done();
            },
            exipt_world(id){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/ord.order/export?checklist_id="+id,
                    type:'GET',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();

                        window.open(res.data,'_blank')
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })


            },
            exit(){
                this.$confirm('确认退出？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.add_form={
                        check_name:'',
                            check_no:'',
                            outbound_name:'',
                            outbound_uid:'',
                            goodsc_item:[]
                    }
                    this.dialogVisible = false
                })
            },
            get_list_time(){
                var timdedetail = this.value1[0]
                this.data.status_time = this.getData(timdedetail)

                var end_time = this.value1[1]
                this.data.end_time = this.getData(end_time)

                this.get_list()
            },
            getData(timdedetail){
                var year=timdedetail.getFullYear();
                var month=(timdedetail.getMonth()+1)>=10?timdedetail.getMonth()+1:'0'+(timdedetail.getMonth()+1);
                var date=timdedetail.getDate()>=10?timdedetail.getDate():'0'+timdedetail.getDate();
                var hours=timdedetail.getHours()>=10?timdedetail.getHours():'0'+timdedetail.getHours();
                var minutes=timdedetail.getMinutes()>=10?timdedetail.getMinutes():'0'+timdedetail.getMinutes();
                var seconds=timdedetail.getSeconds()>=10?timdedetail.getSeconds():'0'+timdedetail.getSeconds();;
                var time=year+"-"+month+"-"+date+" "+hours+":"+minutes+":"+seconds;
                return time
            },
            save_pandian(num){
                var form_data = {
                    checklist_id:this.pandian_detail.id,
                    status:num,
                    goodsc_item:[]
                }
                this.pandian_detail.goodsc_item.map(item=>{
                    form_data.goodsc_item.push({
                        chitem_id:item.id,
                        physical_inventory:item.physical_inventory,
                        remarks:item.remarks,
                        check_no:this.pandian_detail.check_no,
                        gid:item.gid,
                        good_type_id:item.good_type_id,
                        good_type_name:item.good_type_name,
                        stock:item.stock,
                        // receipt_issue_num:item.stock,
                    })
                })
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/chel.Checklist/edit",
                    data:form_data,
                    type:'POST',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                            this.dialogVisible = false
                            this.get_list()

                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })

            },
            do_pandian(data){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/chel.Checklist/chkgoodc_detail",
                    data:{checklist_id:data.id},
                    type:'GET',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            this.dialogVisible = true;
                            this.active_int=4;
                            this.pandian_detail = res.data.row
                            this.pandian_detail.goodsc_item = res.data.checklist_item
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })
            },
            on_delete(id){
                this.$confirm('确认删除？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    const loading = this.$loading({
                        lock: true,
                        text: 'Loading',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    $.ajax({
                        url:"/admin/chel.checklist/delete",
                        type:'POST',
                        data:{id},
                        dataType: 'json',
                        success:(res)=>{
                            loading.close();
                            if(res.code==1){
                                this.$message({
                                    type: 'success',
                                    message: res.msg
                                });
                                this.get_list()
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        },
                        error:()=>{
                            loading.close();
                            this.$message({
                                type: 'info',
                                message: '网络状态差'
                            });
                        }
                    })
                })
            },
            onEdit(){
                this.add_form.checklist_id = this.add_form.id
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/chel.checklist/upedit",
                    type:'POST',
                    data:this.add_form,
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            this.add_form = {
                                check_name:'',
                                    check_no:'',
                                    outbound_name:'',
                                    outbound_uid:'',
                                    goodsc_item:[]
                            }
                            // this.multipleSelection = [];
                            this.$refs.multipleTable.clearSelection();
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                            this.dialogVisible = false
                            this.get_list()
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })
            },
            del_good(id){
                this.$confirm('确认删除？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var index = this.add_form.goodsc_item.findIndex(d=>d.gid==id)
                    this.add_form.goodsc_item.splice(index,1)
                })
            },

            toggleSelection(rows) {
                if (rows) {
                    rows.forEach(row => {
                        this.$refs.multipleTable.toggleRowSelection(row);
                    });
                } else {
                    this.$refs.multipleTable.clearSelection();
                }
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
                // this.sel_goodsarr = val
            },
            add_success(){
                var goodsc_item = []
                // this.add_form.goodsc_item = this.multipleSelection
                this.multipleSelection.map(item=>{
                    goodsc_item.push({
                        gid:item.id,
                        good_type_id:item.good_type_id,
                        good_name:item.title,
                        good_type_name:item.good_type_name,
                        stock:item.stock
                    })
                })
                this.add_form.goodsc_item = goodsc_item
                this.innerVisible = false
            },
            search(){},
            keydown(e){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                if(e.keyCode === 13){
                    $.ajax({
                        url:"/admin/gwa.goods_warehousing/get_tmgood",
                        type:'POST',
                        data:this.order_code_form,
                        dataType: 'json',
                        success:(res)=>{
                            loading.close();
                            if(res.code==1){
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        },
                        error:()=>{
                            loading.close();
                            this.$message({
                                type: 'info',
                                message: '网络状态差'
                            });
                        }
                    })
                }
            },
            add_shop(){

                this.innerVisible=true;
                setTimeout(()=>{
                    this.add_form.goodsc_item.forEach(row => {
                        var item = this.goodsArr.find(d=>d.id==row.gid)
                        this.$refs.multipleTable.toggleRowSelection(item,true);
                    });
                },500)


            },
            onSave(){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/chel.checklist/add",
                    type:'POST',
                    data:this.add_form,
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            this.add_form = {
                                check_name:'',
                                check_no:'',
                                outbound_name:'',
                                outbound_uid:'',
                                goodsc_item:[]
                            }
                            // this.multipleSelection = [];
                            this.$refs.multipleTable.clearSelection();

                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                            this.dialogVisible = false
                            this.get_list()
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })
            },
            success(){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/ord.order/change_information",
                    data:{change_info:this.change_info_val,id:this.change_info_id},
                    type:'POST',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            var item = this.dataArr.find(d=>d.id==this.change_info_id)
                            item.change_info = this.change_info_val
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })
                this.dialogVisible_change = false
            },
            change_info(id){
                this.dialogVisible_change = true
                this.change_info_id = id
            },
            cancel_order(id){
                this.$confirm('是否取消此订单？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    const loading = this.$loading({
                        lock: true,
                        text: 'Loading',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    $.ajax({
                        url:"/admin/ord.order/cancel_order",
                        data:{id},
                        type:'POST',
                        dataType: 'json',
                        success:(res)=>{
                            loading.close();
                            if(res.code==1){
                                var item = this.dataArr.find(d=>d.id==id)
                                item.status = 7
                                this.$message({
                                    type: 'success',
                                    message: res.msg
                                });
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        },
                        error:()=>{
                            loading.close();
                            this.$message({
                                type: 'info',
                                message: '网络状态差'
                            });
                        }
                    })
                }).catch(() => {
                });
            },
            examine(id){
                this.$confirm('修改变更审核状态', '审核', {
                    distinguishCancelAndClose: true,
                    center:true,
                    confirmButtonText: '通过',
                    cancelButtonText: '驳回',
                    type: 'warning',
                    beforeClose:(action, instance, done)=>{
                        if(action=='confirm'){
                            const loading = this.$loading({
                                lock: true,
                                text: 'Loading',
                                spinner: 'el-icon-loading',
                                background: 'rgba(0, 0, 0, 0.7)'
                            });
                            $.ajax({
                                url:"/admin/chao.change_order/change_order_review",
                                data:{id},
                                type:'POST',
                                dataType: 'json',
                                success:(res)=>{
                                    loading.close();
                                    if(res.code==1){
                                        var item = this.dataArr.find(d=>d.id==id)
                                        item.change_status = 2
                                        this.$message({
                                            type: 'success',
                                            message: res.msg
                                        });
                                    }else{
                                        this.$message({
                                            type: 'info',
                                            message: res.msg
                                        });
                                    }
                                    done()
                                },
                                error:()=>{
                                    loading.close();
                                    this.$message({
                                        type: 'info',
                                        message: '网络状态差'
                                    });
                                }
                            })
                        }else if(action=='cancel'){
                            const loading = this.$loading({
                                lock: true,
                                text: 'Loading',
                                spinner: 'el-icon-loading',
                                background: 'rgba(0, 0, 0, 0.7)'
                            });
                            $.ajax({
                                url:"/admin/chao.change_order/change_order_refuse",
                                data:{id,change_reason:'驳回'},
                                type:'POST',
                                dataType: 'json',
                                success:(res)=>{
                                    loading.close();
                                    if(res.code==1){
                                        var item = this.dataArr.find(d=>d.id==id)
                                        item.change_status = 3
                                        this.$message({
                                            type: 'success',
                                            message: res.msg
                                        });
                                    }else{
                                        this.$message({
                                            type: 'info',
                                            message: res.msg
                                        });
                                    }
                                },
                                error:()=>{
                                    loading.close();
                                    this.$message({
                                        type: 'info',
                                        message: '网络状态差'
                                    });
                                }
                            })
                            done()
                        }else{
                            done()
                        }
                    }
                })
            },
            onSubmit(){
                if(this.add_form.check_name){
                    this.add_form = {
                        check_name:'',
                        check_no:'',
                        outbound_name:'',
                        outbound_uid:'',
                        goodsc_item:[]
                    }
                }
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/chel.Checklist/pdincoming_data",
                    type:'GET',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            this.dialogVisible = true;
                            this.active_int=3;
                            this.add_form.check_no = res.data.check_no
                            this.add_form.outbound_name = res.data.outbound_name
                            this.add_form.outbound_uid = res.data.outbound_uid
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })
            },
            detail_show(data){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/chel.Checklist/chkgoodc_detail",
                    data:{checklist_id:data.id},
                    type:'GET',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            this.dialogVisible = true;
                            this.active_int=1;
                            this.detail_obj = res.data.row
                            this.detail_obj.checklist_item = res.data.checklist_item
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })
            },
            edit_show(data){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/chel.Checklist/chkgoodc_detail",
                    data:{checklist_id:data.id},
                    type:'GET',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            this.dialogVisible = true;
                            this.active_int=2;
                            this.add_form = res.data.row
                            this.add_form.goodsc_item = res.data.checklist_item
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'info',
                            message: '网络状态差'
                        });
                    }
                })

            },
            notes_show(data){
                this.$prompt('请输备注', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern: /\S+/,
                    inputErrorMessage: '备注不能为空'
                }).then(({ value }) => {
                    const loading = this.$loading({
                        lock: true,
                        text: 'Loading',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    $.ajax({
                        url:'/admin/chel.Checklist/chkedit_remark',
                        data:{id:data.id,reamark:value},
                        dataType:"json",
                        success:(res)=>{
                            loading.close();
                            if(res.code==1){
                                this.$message({
                                    type: 'success',
                                    message:res.msg
                                });
                                var item = this.dataArr.find(d=>d.id==data.id)
                                item.remark = value
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        },
                        error:()=>{
                            loading.close();
                            this.$message({
                                type: 'info',
                                message: '网络状态差'
                            });
                        }
                    })

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '取消输入'
                    });
                });
            },
            createOrder(){
                window.location.href = '/admin/ord.order/add'
            },
            handleSizeChange(val){
                this.data.limit = val
                this.get_list()
            },
            handleCurrentChange(val) {
                this.data.page = val
                this.get_list()
            },
            get_list(){

                $.ajax({
                    url:'/admin/chel.checklist/index',
                    data:this.data,
                    dataType:"json",
                    success:(res)=>{
                        this.dataArr = res.data
                        this.total = res.count
                    }
                })
            },
            goodsarr(){
                var that = this
                var data={}
                if(this.formInline.good_type_id){
                    data.good_type_id = this.formInline.good_type_id
                }
                if(this.formInline.title){
                    data.title = this.formInline.title
                }
                $.ajax({
                    url: '/admin/ord.order/get_goodsarr',
                    type: 'GET',
                    data:this.formInline,
                    dataType: 'json',
                    success: function (res) {
                        that.goodsArr = res.data
                    }
                })
            },
        },
        mounted() {
            var that = this
            $.ajax({
                url: '/admin/ord.order/good_type',
                type: 'POST',
                dataType: 'json',
                success: function (res) {
                    that.good_type = res.data
                }
            })
            this.goodsarr()
        }
    })
</script>